import { http } from '@/utils/request'

export const newsCreateApi = (data: FormData) => {
    return http.post('/adminapi/news/create', data, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}

export const getNewsListApi = (id?: string) => {
    if (id) {
        return http.get(`/adminapi/news/list/${id}`)
    }
    return http.get(`/adminapi/news/list/all`)
}

export const changeStatusApi = (id: number) => {
    return http.put(`/adminapi/news/status/${id}`)
}

export const deleteNewsApi = (id: number) => {
    return http.delete(`/adminapi/news/delete/${id}`)
}

export const editNewsApi = (data: FormData) => {
    return http.post('/adminapi/news/edit', data, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}